import axios from 'axios'
import { localGet } from '@/utils/mylocal.js'
const myhttp = axios.create({
  baseURL: 'https://autumnfish.cn/heimamm_server/'
  // baseURL: 'http://localhost:1337'
})
export { myhttp }
// 请求拦截
myhttp.interceptors.request.use(
  function (config) {
    if (config.needToken) {
      const token = localGet('token')
      if (token) {
        config.headers.authorization = `Bearer ${localGet('token')}`
      }
    }

    return config
  },
  function (error) {
    // Do something with request error
    return Promise.reject(error)
  }
)

// 响应拦截
myhttp.interceptors.response.use(
  function (response) {
    // Do something with response data
    return response
  },
  function (error) {
    // Do something with response error
    return Promise.reject(error)
  }
)
